<template>
	<view class="nav-container">
		<view class="nav-list">
			<view class="nav-item" v-for="(item, index) in iconList" :key="index" @click="tabPage(index)">
				<view class="item-img">
					<image :src="item.icon" mode="" style="width: 40rpx; height: 40rpx;"></image>
				</view>
				<view :class="[index === active ? 'item-title' : '']">{{ item.title }}</view>
			</view>
		</view>
		
		<!-- 点击客服弹窗 -->
		<uni-popup ref="service" :mask-click="false" backgroundColor="#fff">
			<view class="" style="position: relative;">
				<view class="" style="text-align: center;">选择联系客服</view>
				
				<view class="flex" style="border: 5rpx solid rgb(78, 232, 201); border-radius: 20rpx;">
					<view class="" style="display: flex; align-items: center;">
						<view class="">
							<image src="../../static/images/service-Popup-icon1.png"></image>
						</view>
						<view class="">
							<view class="">在线客服</view>
							<view class="" style="color: #999;">在线对话快速受理</view>
						</view>
					</view>
					
					<view class="" style="color: rgb(78, 232, 201);">></view>
				</view>
				
				<view class="flex" style="border: 5rpx solid rgb(12, 157, 227); border-radius: 20rpx;">
					<view class="" style="display: flex; align-items: center;">
						<view class="">
							<image src="../../static/images/service-Popup-icon3.png"></image>
						</view>
						<view class="">
							<view class="">平台服务</view>
							<view class="" style="color: #999;">呼叫平台</view>
						</view>
					</view>
					
					<view class="" style="color: rgb(12, 157, 227);">></view>
				</view>
				
				<view class="">
					<image class="close-icon" src="../../static/images/close.png" @click="colseService"></image>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name:"mallNav",
		props: {
			active: {
				type: Number,
				default: 0
			},
			iconList: {
				type: Array,
				default: [{title: '首页',icon: require('../../static/images/shop-icon-index-hover.png')},
				{title: '分类', icon: require('../../static/images/shop-icon-classify.png')},
				{title: '客服', icon: require('../../static/images/shop-icon-service.png')},
				{title: '我的', icon: require('../../static/images/shop-icon-mine.png')}]
			}
		},
		data() {
			return {
			};
		},
		methods: {
			tabPage(index) {
				if(index === 3) {
					uni.switchTab({
						url: '/pages/my/my'
					})
				}else if(index === 1) {
					if(this.active === 1) return
					uni.navigateTo({
						url: '/pages/shopmall/mallCate'
					})
				}else if(index === 0) {
					if(this.active === 0) return
					uni.navigateTo({
						url: '/pages/shopmall/mallIndex'
					})
				}else {
					this.openService()
				}
			},
			openService() {
				this.$refs.service.open()
			},
			colseService() {
				this.$refs.service.close()
			},
		},
	}
</script>

<style scoped>
	.nav-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}
	.nav-list {
		background-color: #fff;
		padding: 20rpx 35rpx;
		color: #999;
		font-size: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
	}
	.nav-item {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
	}
	.item-title {
		color: #ff0000;
	}
	
	.flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 500rpx;
		font-size: 30rpx;
		line-height: 1.2rem;
		padding: 20rpx 30rpx;
		margin-top: 20rpx;
	}
	.flex image {
		width: 50rpx;
		height: 50rpx;
	}
	.close-icon {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		top: 120%;
		left: 50%	;
		transform: translateX(-50%);
	}
</style>